package com.roger.homecenterscreen.data.api

import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query

/**
 * 天气API接口 - 使用和风天气API
 * 官网：https://dev.qweather.com/
 */
interface WeatherApiService {
    
    /**
     * 获取实时天气
     * @param location 位置信息，可以是城市名或经纬度
     * @param key API密钥
     */
    @GET("v7/weather/now")
    suspend fun getCurrentWeather(
        @Query("location") location: String,
        @Query("key") key: String
    ): Response<QWeatherNowResponse>
    
    /**
     * 获取逐小时天气预报
     * @param location 位置信息
     * @param key API密钥
     */
    @GET("v7/weather/24h")
    suspend fun getHourlyWeather(
        @Query("location") location: String,
        @Query("key") key: String
    ): Response<QWeatherHourlyResponse>
    
    /**
     * 获取3天天气预报
     * @param location 位置信息
     * @param key API密钥
     */
    @GET("v7/weather/3d")
    suspend fun getDailyWeather(
        @Query("location") location: String,
        @Query("key") key: String
    ): Response<QWeatherDailyResponse>
    
    /**
     * 获取空气质量
     * @param location 位置信息
     * @param key API密钥
     */
    @GET("v7/air/now")
    suspend fun getAirQuality(
        @Query("location") location: String,
        @Query("key") key: String
    ): Response<QWeatherAirResponse>
}

// 和风天气API响应数据结构
data class QWeatherNowResponse(
    val code: String,
    val updateTime: String,
    val fxLink: String,
    val now: QWeatherNow,
    val refer: QWeatherRefer
)

data class QWeatherNow(
    val obsTime: String,
    val temp: String,
    val feelsLike: String,
    val icon: String,
    val text: String,
    val wind360: String,
    val windDir: String,
    val windScale: String,
    val windSpeed: String,
    val humidity: String,
    val precip: String,
    val pressure: String,
    val vis: String,
    val cloud: String,
    val dew: String
)

data class QWeatherHourlyResponse(
    val code: String,
    val updateTime: String,
    val fxLink: String,
    val hourly: List<QWeatherHourly>,
    val refer: QWeatherRefer
)

data class QWeatherHourly(
    val fxTime: String,
    val temp: String,
    val icon: String,
    val text: String,
    val wind360: String,
    val windDir: String,
    val windScale: String,
    val windSpeed: String,
    val humidity: String,
    val pop: String,
    val precip: String,
    val pressure: String,
    val cloud: String,
    val dew: String
)

data class QWeatherDailyResponse(
    val code: String,
    val updateTime: String,
    val fxLink: String,
    val daily: List<QWeatherDaily>,
    val refer: QWeatherRefer
)

data class QWeatherDaily(
    val fxDate: String,
    val sunrise: String,
    val sunset: String,
    val moonrise: String,
    val moonset: String,
    val moonPhase: String,
    val moonPhaseIcon: String,
    val tempMax: String,
    val tempMin: String,
    val iconDay: String,
    val textDay: String,
    val iconNight: String,
    val textNight: String,
    val wind360Day: String,
    val windDirDay: String,
    val windScaleDay: String,
    val windSpeedDay: String,
    val wind360Night: String,
    val windDirNight: String,
    val windScaleNight: String,
    val windSpeedNight: String,
    val humidity: String,
    val precip: String,
    val pressure: String,
    val vis: String,
    val cloud: String,
    val uvIndex: String
)

data class QWeatherAirResponse(
    val code: String,
    val updateTime: String,
    val fxLink: String,
    val now: QWeatherAir,
    val station: List<QWeatherAirStation>,
    val refer: QWeatherRefer
)

data class QWeatherAir(
    val pubTime: String,
    val aqi: String,
    val level: String,
    val category: String,
    val primary: String,
    val pm10: String,
    val pm2p5: String,
    val no2: String,
    val so2: String,
    val co: String,
    val o3: String
)

data class QWeatherAirStation(
    val name: String,
    val id: String,
    val aqi: String,
    val level: String,
    val category: String,
    val primary: String,
    val pm10: String,
    val pm2p5: String,
    val no2: String,
    val so2: String,
    val co: String,
    val o3: String
)

data class QWeatherRefer(
    val sources: List<String>,
    val license: List<String>
) 